 #include <iostream>
#include <string>

int main() {
    std::string a;
    std::cout << "Введите последовательность:";
    std::cin >> a;

    bool replaced;
    do {
        replaced = false;
        size_t pos;
        if ((pos = a.find("()")) != std::string::npos) {
            a.erase(pos, 2);
            replaced = true;
        }
        if ((pos = a.find("[]")) != std::string::npos) {
            a.erase(pos, 2);
            replaced = true;
        }
        if ((pos = a.find("{}")) != std::string::npos) {
            a.erase(pos, 2);
            replaced = true;
        }
        if ((pos = a.find("<>")) != std::string::npos) {
            a.erase(pos, 2);
            replaced = true;
        }
    } while (replaced);

    if (!a.empty()) {
        std::cout << "False" << std::endl;
    } else {
        std::cout << "True" << std::endl;
    }

    return 0;
}
